package com.tengju.data.domain.model.user;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

@Getter
@AllArgsConstructor
public enum IsDirect {


    NO(0,false,"非直属"),
    YES(1,true,"直属"),
    ;

    Integer val;
    Boolean booleanVal;
    String desc;

    public static IsDirect parseByVal(Integer val) {
        if (val == null) {
            return null;
        }
        return Arrays.stream(IsDirect.values())
                .filter(k -> k.getVal().equals(val))
                .findFirst().orElse(null);
    }

    public static IsDirect parseByBooleanVal(Boolean booleanVal) {
        if (booleanVal == null) {
            return null;
        }
        return Arrays.stream(IsDirect.values())
                .filter(k -> k.getBooleanVal().equals(booleanVal))
                .findFirst().orElse(null);
    }

}
